package leetcode;

/**
 * @author:xufengxiang
 * @date 2023-03-13 20:07
 */
public class Code12 {


    public static String intToRoman(int num) {
        int[] values = {1000, 900,500,400,100,90,50,40,10,9,5,4,1};
        String[] characters = {"M", "CM", "D", "CD", "C","XC", "L","XL","X", "IX","V","IV", "I"};

        int i=0;
        StringBuilder sb = new StringBuilder();
        while(i< values.length && num >0){
            if(num < values[i]){
                i++;
                continue;
            }
            num = num - values[i];
            sb.append(characters[i]);
        }
        return sb.toString();

    }

    public static void main(String[] args) {
        System.out.println(intToRoman(1994));
    }


}
